import { onShow } from '@dcloudio/uni-app';
export const cellClick = () => {
  // 返回上一页并刷新数据方法
  let pages = getCurrentPages(); // 当前页面
  let beforePage = pages[pages.length - 2]; // 上一页
  (beforePage as any).data.refreshIfNeeded = true;
  uni.navigateBack({ delta: 1 });
};

export const useBack = (callBack: Function) => {
  onShow(() => {
    let pages = getCurrentPages(); // 获取当前页面栈
    let currentPage = pages[pages.length - 1]; // 当前页面
    if ((currentPage as any).data.refreshIfNeeded) {
      (currentPage as any).data.refreshIfNeeded = false;
      callBack();
    }
  });
};
